package com.tc.vms.message;

import com.tc.vms.MessageWrap;
import com.tc.vms.utils.Utils;

import java.util.HashSet;

/**
 * Created by yonghua.zhang on 2016/1/8.
 */
public final class MessageConst {

    public static final String HOSTNAME = Utils.getHostIp();
    public static final String VMS_MESSAGE_ENCODING = "UTF-8";
    public static final String VMS_MESSAGE_CONTENT_TYPE = "text/plain";

    public static final String PROPERTY_KEYS = "KEYS";
    public static final String PROPERTY_TAGS = "TAGS";
    public static final String PROPERTY_DELAY_TIME_LEVEL = "DELAY";
    public static final String PROPERTY_BUYER_ID = "BUYER_ID";
    public static final String PROPERTY_RECONSUME_TIME = "RECONSUME_TIME";
    public static final String PROPERTY_BORN_HOST = "BORN_HOST";
    public static final String PROPERTY_CONTENT_ENCODING = "C_ENCODING";
    public static final String PROPERTY_CONTENT_TYPE = "C_TYPE";
    public static final String PROPERTY_TTL = "TTL";
    public static final String PROPERTY_PRIORITY = "PRIORITY";
    public static final String PROPERTY_BORN_TIMESTAMP = "BORN_TIMESTAMP";
    public static final String PROPERTY_STROE_TIMESTAMP = "STORE_TIMESTAMP";
    public static final String PROPERTY_USER_ID = "USER_ID";
    public static final String PROPERTY_APP_ID = "APP_ID";

    public static final int MESSAGE_MAX_SIZE = 1024 * 900;
    public static final HashSet<String> systemKeySet = new HashSet<String>();

    static {
        systemKeySet.add(PROPERTY_KEYS);
        systemKeySet.add(PROPERTY_TAGS);
        systemKeySet.add(PROPERTY_DELAY_TIME_LEVEL);
        systemKeySet.add(PROPERTY_BUYER_ID);
        systemKeySet.add(PROPERTY_RECONSUME_TIME);
        systemKeySet.add(PROPERTY_CONTENT_ENCODING);
        systemKeySet.add(PROPERTY_CONTENT_TYPE);
        systemKeySet.add(PROPERTY_TTL);
        systemKeySet.add(PROPERTY_PRIORITY);
        systemKeySet.add(PROPERTY_BORN_TIMESTAMP);
        systemKeySet.add(PROPERTY_STROE_TIMESTAMP);
        systemKeySet.add(PROPERTY_USER_ID);
        systemKeySet.add(PROPERTY_APP_ID);
    }

    public static void setMessageReconsumeTimes(MessageWrap message, int times) {
        message.setAttribute(PROPERTY_RECONSUME_TIME, String.valueOf(times));
    }
}
